* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: #f5f5f5;
  color: #222;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- TOP BAR ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  z-index: 10;
}

#logo {
  font-size: 20px;
  font-weight: 700;
  color: #667eea;
  white-space: nowrap;
}

#create-area {
  display: flex;
  gap: 12px;
  flex: 1;
  max-width: 600px;
}

#inp-name {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  outline: none;
  background: #fafafa;
  transition: all 0.2s;
}
#inp-name:focus { 
  border-color: #667eea; 
  background: #fff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
#inp-name::placeholder { color: #999; }

#btn-create {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
#btn-create:hover { 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ---- CONTENT ---- */
#content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- SIDEBAR ---- */
aside#sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

#sidebar-header {
  padding: 16px 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  border-bottom: 1px solid #f0f0f0;
}

nav#nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

nav#nav .nav-item {
  padding: 12px 16px;
  font-size: 14px;
  color: #444;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
  transition: all 0.15s;
}
nav#nav .nav-item:hover { background: #f5f5f5; }
nav#nav .nav-item.active { 
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
}

#side-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}
#side-actions button {
  padding: 10px 16px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}
#side-actions button:hover:not(:disabled) { 
  background: #f0f0f0; 
  color: #222;
  border-color: #ccc;
}
#side-actions button:disabled { 
  opacity: 0.4; 
  cursor: default;
  background: #f5f5f5;
}
#btn-export {
  color: #667eea;
  border-color: #c5cae9;
}
#btn-export:hover:not(:disabled) { 
  background: #e8eaf6; 
  border-color: #667eea;
}
#btn-delete { 
  color: #b44; 
  border-color: #e8c8c8; 
}
#btn-delete:hover:not(:disabled) { 
  background: #fdf0f0; 
  color: #922;
  border-color: #d4a5a5;
}

/* ---- MAIN ---- */
main#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f5f5f5;
}

h1#title {
  padding: 20px 28px 16px;
  font-size: 22px;
  font-weight: 600;
  color: #222;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
}

#placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 16px;
  background: #f5f5f5;
}

#grid-area {
  flex: 1;
  overflow: auto;
  padding: 20px 28px;
  display: none;
  background: #f5f5f5;
}

/* ---- TABLE ---- */
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

thead { 
  position: sticky; 
  top: 0; 
  z-index: 5; 
}

.g-ia {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 10px 12px;
  text-align: center;
}
.g-user {
  background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 10px 12px;
  text-align: center;
}
#row-group th:last-child { 
  background: #f0f0f0; 
  width: 40px;
  border-bottom: 1px solid #ddd;
}

#row-cols th {
  background: #fafafa;
  color: #666;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid #e8e8e8;
}
#row-cols th:nth-child(1), #row-cols th:nth-child(5) { width: 100px; }
#row-cols th:nth-child(2), #row-cols th:nth-child(6) { width: 160px; }
#row-cols th:nth-child(4), #row-cols th:nth-child(8) { width: 180px; }
#row-cols th:last-child { width: 40px; }

td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
  font-size: 14px;
  height: 48px;
}

td.s-ia { 
  background: linear-gradient(135deg, #f7f9ff 0%, #f0f4ff 100%);
  border-left: 3px solid #667eea;
}
td.s-user { 
  background: #fffbf7; 
}
tr:hover td.s-ia { 
  background: linear-gradient(135deg, #eef2ff 0%, #e5ebff 100%);
}
tr:hover td.s-user { 
  background: #fff5eb; 
}

.c-mrf {
  font-family: 'SF Mono', monospace;
  font-size: 11px;
  color: #a0aec0;
  padding-top: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-readonly {
  min-height: 32px;
  padding: 10px 12px;
  outline: none;
  border-radius: 6px;
  line-height: 1.5;
  background: rgba(102, 126, 234, 0.06);
  border: 1px dashed rgba(102, 126, 234, 0.3);
  color: #4a5568;
  font-style: italic;
}
.c-readonly:empty::before {
  content: '—';
  color: #cbd5e0;
}

.c-edit {
  min-height: 32px;
  padding: 10px 12px;
  outline: none;
  cursor: text;
  border-radius: 6px;
  line-height: 1.5;
  transition: all 0.15s;
}
.c-edit:hover { background: rgba(237, 137, 54, 0.05); }
.c-edit:focus { 
  background: #fff; 
  box-shadow: inset 0 0 0 2px #ed8936;
}

.c-att {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 4px;
}
.c-att.dragover { 
  background: #e8f0fb; 
  border-radius: 6px;
}

.att-item { position: relative; }
.att-img {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  transition: all 0.15s;
}
.att-img:hover { 
  border-color: #667eea;
  transform: scale(1.05);
}
.att-x {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  background: #e53e3e;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.att-item:hover .att-x { display: flex; }

.att-plus {
  width: 38px;
  height: 38px;
  border: 2px dashed #cbd5e0;
  border-radius: 6px;
  background: transparent;
  color: #a0aec0;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.att-plus:hover { 
  border-color: #ed8936; 
  color: #ed8936;
  background: rgba(237, 137, 54, 0.05);
}

.att-url {
  width: 90px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  color: #666;
  outline: none;
  background: #fafafa;
  transition: all 0.2s;
}
.att-url:focus { 
  border-color: #ed8936; 
  width: 140px; 
  background: #fff;
  box-shadow: 0 0 0 3px rgba(237, 137, 54, 0.1);
}
.att-url::placeholder { color: #bbb; }

.del {
  background: transparent;
  border: none;
  color: #cbd5e0;
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  transition: color 0.15s;
}
.del:hover { color: #e53e3e; }
