*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg:        #2e3136;
    --surface:   #3c5454;
    --surface-2: #344848;
    --surface-3: #2a3d3d;
    --text:      #edeff5;
    --text-muted:#bec2d0;
    --accent:    #5dcaa5;
    --accent-dim:#3c8a70;
    --danger:    #e05c5c;
    --danger-dim:#7a2e2e;
    --border:    rgba(190,194,208,.12);
    --radius:    10px;
    --radius-sm: 6px;
    --shadow:    0 4px 24px rgba(0,0,0,.35);
    --mono:      'JetBrains Mono', monospace;
    --sans:      'Inter', system-ui, sans-serif;
  }

  body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
  }

  /* ── Login ── */
  .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
  }
  .login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px 40px;
    box-shadow: var(--shadow);
  }
  .login-logo {
    width: 110px;
    height: 40px;
    
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin: 0 auto 32px;
  }
  .login-title {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 6px;
  }
  .login-sub {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
  }
  .form-group { margin-bottom: 16px; }
  .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
  }
  .form-group input, .form-group select, .form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    transition: border-color .15s;
  }
  .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
  }
  .form-group textarea { resize: vertical; min-height: 72px; font-family: var(--mono); font-size: 13px; }
  .form-group select option { background: var(--surface-3); }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
    text-decoration: none;
  }
  .btn:hover { opacity: .88; transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .btn-primary { background: var(--accent); color: #1a2e27; width: 100%; justify-content: center; font-size: 14px; padding: 12px; }
  .btn-sm { padding: 6px 12px; font-size: 12px; }
  .btn-danger { background: var(--danger-dim); color: #ffcccc; border: 1px solid var(--danger); }
  .btn-ghost  { background: var(--border); color: var(--text-muted); border: 1px solid var(--border); }
  .btn-edit   { background: rgba(60,84,84,.8); color: var(--accent); border: 1px solid var(--surface); }

  .alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
  }
  .alert-error   { background: var(--danger-dim); border: 1px solid var(--danger); color: #ffcccc; }
  .alert-success { background: rgba(93,202,165,.12); border: 1px solid var(--accent-dim); color: var(--accent); }

  /* ── App Layout ── */
  .app { display: flex; flex-direction: column; min-height: 100vh; }

  .topbar {
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .topbar-left { display: flex; align-items: center; gap: 16px; }
  .topbar-logo {
    width: 42px;
    height: 20px;
    
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: .07em;
    text-transform: uppercase;
  }
  .topbar-divider { width: 1px; height: 24px; background: var(--border); }
  .topbar-domain {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    background: rgba(93,202,165,.08);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(93,202,165,.2);
  }
  .topbar-right { display: flex; align-items: center; gap: 12px; }
  .topbar-user { font-size: 12px; color: var(--text-muted); }

  .main { flex: 1; padding: 32px; max-width: 1200px; margin: 0 auto; width: 100%; }

  .page-header { margin-bottom: 28px; }
  .page-header h1 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
  .page-header p  { font-size: 13px; color: var(--text-muted); }

  /* ── Add Form Card ── */
  .card {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
  }
  .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
  }
  .card-header h2 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
  .card-header .chevron { transition: transform .2s; color: var(--text-muted); font-size: 12px; }
  .card-header.open .chevron { transform: rotate(180deg); }
  .card-body { padding: 20px; display: none; }
  .card-body.open { display: block; }

  .add-grid {
    display: grid;
    grid-template-columns: 140px 1fr 1fr 90px;
    gap: 12px;
    align-items: end;
  }
  .add-grid .span2 { grid-column: span 2; }
  .add-grid .span4 { grid-column: span 4; }

  /* ── Table ── */
  .table-card { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .table-toolbar {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .table-toolbar h2 { font-size: 14px; font-weight: 600; }
  .search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    flex: 1;
    max-width: 280px;
  }
  .search-box input {
    background: none;
    border: none;
    color: var(--text);
    font-size: 13px;
    width: 100%;
    outline: none;
    font-family: var(--sans);
  }
  .search-icon { color: var(--text-muted); font-size: 13px; }

  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(0,0,0,.15);
    border-bottom: 1px solid var(--border);
  }
  tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
  tbody tr:last-child { border-bottom: none; }
  tbody tr:hover { background: rgba(255,255,255,.025); }
  td { padding: 12px 16px; vertical-align: middle; }

  .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--mono);
    letter-spacing: .04em;
  }

  .record-value {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .record-name { font-family: var(--mono); font-size: 13px; }
  .ttl-cell { font-family: var(--mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

  .actions-cell { display: flex; gap: 6px; justify-content: flex-end; }

  /* ── Modal ── */
  /* ── Loader global ── */
  .loader-overlay {
    position: fixed; inset: 0;
    background: rgba(20,25,30,.78);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
  }
  .loader-overlay.active { display: flex; }
  .spinner {
    width: 44px; height: 44px;
    border: 3px solid rgba(190,194,208,.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loader-text {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: .03em;
  }

  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(20,25,30,.75);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
    animation: modal-in .18s ease;
  }
  @keyframes modal-in {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }
  .modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .modal-header h3 { font-size: 15px; font-weight: 600; }
  .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color .15s;
  }
  .modal-close:hover { color: var(--text); }
  .modal-body { padding: 20px 24px; }
  .modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

  /* ── Empty / Error states ── */
  .state-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
  }
  .state-empty .icon { font-size: 32px; margin-bottom: 12px; opacity: .4; }

  /* ── Footer ── */
  .footer {
    text-align: center;
    padding: 24px;
    font-size: 11px;
    color: rgba(190,194,208,.3);
    letter-spacing: .05em;
  }

  /* ── Responsive ── */
  @media (max-width: 700px) {
    .topbar { padding: 0 16px; }
    .main { padding: 16px; }
    .add-grid { grid-template-columns: 1fr 1fr; }
    .add-grid .span2, .add-grid .span4 { grid-column: span 2; }
    .record-value { max-width: 160px; }
    table { font-size: 12px; }
    td, thead th { padding: 10px; }
  }