*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: #0a0e13;
    color: #e6edf3;
    font-family: system-ui, -apple-system, "Segoe UI", "Tahoma", sans-serif;
}

a { color: inherit; }

/* ===================== Shell / Sidebar ===================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: linear-gradient(190deg, #101922 0%, #0c1219 100%);
    border-inline-start: 1px solid #1b2732;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px 18px;
    border-bottom: 1px solid #1a2530;
    margin-bottom: 14px;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 9px;
    background: linear-gradient(180deg, #14b8a6, #0f9c8c);
    color: #04110f; font-size: 15px; font-weight: 700;
}
.brand-text { color: #e6edf3; font-weight: 700; font-size: 14.5px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 10px;
    color: #93a3b4; text-decoration: none;
    font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent;
    transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: #141f2b; color: #d7e0e9; }
.nav-item.active {
    background: rgba(20, 184, 166, 0.12);
    border-color: rgba(31, 138, 126, 0.5);
    color: #7fe6d8;
}
.nav-ico { font-size: 15px; width: 18px; text-align: center; }

.sidebar-foot {
    font-size: 11px; color: #5c6b7a;
    padding: 12px 10px 4px;
    border-top: 1px solid #1a2530;
    display: flex; align-items: center; gap: 7px;
}
.sidebar-foot .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #14b8a6; box-shadow: 0 0 8px #14b8a6;
}

.app-main { flex: 1; min-width: 0; overflow-x: hidden; }

/* ===================== Page shell ===================== */
.coa-shell, .hm-shell {
    min-height: 100vh;
    padding: 22px 26px 40px;
    overflow-x: hidden;
    background:
        radial-gradient(1100px 380px at 100% 0%, rgba(20, 184, 166, 0.07), transparent 62%),
        radial-gradient(900px 340px at 0% 100%, rgba(56, 108, 168, 0.05), transparent 60%),
        #0a0e13;
}
.hm-shell { padding: 24px 28px 44px; }

.coa-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.coa-breadcrumb, .hm-crumb { font-size: 14px; color: #6b7b8c; }
.coa-breadcrumb .sep, .hm-crumb .sep { margin: 0 7px; color: #33414f; }
.coa-breadcrumb .current, .hm-crumb .current { color: #e6edf3; font-weight: 600; }

/* ===================== Cards ===================== */
.coa-page { display: flex; gap: 18px; align-items: stretch; min-height: 560px; }
.coa-card {
    background: linear-gradient(168deg, #131c26 0%, #0e151d 58%, #0d131a 100%);
    border: 1px solid #1e2a36;
    border-radius: 18px;
    padding: 18px 20px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 28px rgba(0,0,0,0.4);
}
.coa-tree { flex: 1; min-width: 300px; }
.coa-details { flex: 1; }
.je-list-card { flex: 1.55; overflow-x: auto; }
.je-detail-card { flex: 1; min-width: 340px; }

.card-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid #1c2733; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.head-actions { display: flex; gap: 8px; }

.icon-btn {
    background: rgba(20, 184, 166, 0.09);
    border: 1px solid rgba(20, 184, 166, 0.22);
    color: #2dd4bf; width: 32px; height: 32px; border-radius: 9px;
    cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(20, 184, 166, 0.18); border-color: rgba(20, 184, 166, 0.4); }

/* ===================== Buttons ===================== */
.btn {
    border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
    font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: filter .15s ease, background .15s ease;
}
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-primary { background: linear-gradient(180deg, #17c4b1 0%, #0d9488 100%); color: #04231f; box-shadow: 0 3px 14px rgba(20, 184, 166, 0.24); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: rgba(148, 163, 184, 0.06); color: #93a3b4; border-color: #24313f; }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; }
.btn-danger { background: #2a1620; color: #ff9db0; border-color: #4a2233; }
.btn-danger:hover { background: #351a28; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-plus { font-weight: 700; margin-inline-end: 3px; }

/* ===================== Search / toolbar ===================== */
.search-box {
    display: flex; align-items: center; gap: 9px;
    background: rgba(6, 10, 14, 0.6);
    border: 1px solid #1c2733; border-radius: 11px;
    padding: 10px 14px; margin-bottom: 16px; min-width: 260px;
}
.search-box:focus-within { border-color: rgba(20, 184, 166, 0.45); }
.search-box input { border: none; background: transparent; outline: none; font-size: 13px; flex: 1; font-family: inherit; color: #e6edf3; width: 100%; }
.search-box input::placeholder { color: #4d5e70; }
.search-icon { font-size: 13px; opacity: 0.45; }

.je-toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.je-toolbar .search-box { margin-bottom: 0; }
.je-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.je-chip { background: #131c26; border: 1px solid #24313d; color: #8fa1b3; border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: inherit; }
.je-chip.active { background: rgba(20,184,166,0.14); border-color: #1f8a7e; color: #7fe6d8; }

/* ===================== Tables ===================== */
.je-table, .hm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.je-table th, .hm-table th {
    text-align: right; color: #7c8da0; font-weight: 600;
    padding: 9px 10px; border-bottom: 1px solid #1e2a36; white-space: nowrap;
}
.je-table td, .hm-table td { padding: 9px 10px; border-bottom: 1px solid #16202b; color: #d7e0e9; vertical-align: middle; }
.je-table tfoot td, .hm-table tfoot td { border-top: 1px solid #24313d; border-bottom: none; font-weight: 700; color: #e6edf3; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.hm-table .strong { font-weight: 700; color: #e6edf3; }
.hm-table tr.muted td { color: #64748b; }

.je-list tbody tr { cursor: pointer; }
.je-list tbody tr:hover { background: #14202c; }
.je-list tbody tr.selected { background: rgba(20,184,166,0.10); }
.je-desc-cell, .je-desc { color: #9fb0c0; }
.je-desc-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Pills ===================== */
.je-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill-draft { background: rgba(120,140,160,0.15); color: #b7c5d3; }
.pill-posted { background: rgba(20,184,166,0.16); color: #6fe3d4; }
.pill-cancelled { background: rgba(255,120,140,0.14); color: #ff9db0; }

.hm-nat { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.hm-nat.dr { background: rgba(56, 132, 255, 0.14); color: #86b7ff; }
.hm-nat.cr { background: rgba(20, 184, 166, 0.16); color: #6fe3d4; }
.hm-nat.zero { background: rgba(120, 140, 160, 0.14); color: #9fb0c0; }

.hm-tile-v.profit-pos { color: #6fe3d4; }
.hm-tile-v.profit-neg { color: #ff7a7a; }

/* ===================== Details / editor ===================== */
.je-details { display: flex; flex-direction: column; gap: 14px; }
.je-identity { display: flex; justify-content: space-between; align-items: flex-start; }
.je-title { font-size: 15px; font-weight: 700; }
.je-year { color: #6b7b8c; font-weight: 500; }
.je-sub { font-size: 12px; color: #8fa1b3; margin-top: 2px; }
.je-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.je-meta div { display: flex; flex-direction: column; gap: 2px; }
.je-meta span { font-size: 11px; color: #6f8091; }
.je-meta b { font-size: 13px; font-weight: 600; color: #dbe4ec; }
.je-desc { font-size: 13px; line-height: 1.6; background: #0e151d; border: 1px solid #1a2530; border-radius: 10px; padding: 10px 12px; }

.je-editor { display: flex; flex-direction: column; gap: 14px; }
.je-form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.je-field { display: flex; flex-direction: column; gap: 5px; }
.je-field label { font-size: 12px; color: #8fa1b3; }
.je-field input, .je-field select, .je-field textarea,
.je-table-edit input, .je-table-edit select {
    background: #0e151d; border: 1px solid #24313d; border-radius: 8px;
    padding: 7px 9px; color: #e6edf3; font-family: inherit; font-size: 13px; outline: none; width: 100%;
}
.je-field input:focus, .je-field select:focus, .je-field textarea:focus,
.je-table-edit input:focus, .je-table-edit select:focus { border-color: #1f8a7e; }
.je-field textarea { min-height: 56px; resize: vertical; }

.je-lines-head { display: flex; justify-content: space-between; align-items: center; }
.je-lines-head span { font-size: 13px; font-weight: 700; color: #cdd9e5; }
.je-table-edit td { padding: 6px 6px; }
.je-row-del { background: #241722; border: 1px solid #43263a; color: #ff9db0; border-radius: 7px; width: 28px; height: 28px; cursor: pointer; }
.je-row-del:disabled { opacity: .35; cursor: not-allowed; }

.je-balance { font-size: 12px; font-weight: 700; }
.je-balance.ok { color: #6fe3d4; }
.je-balance.bad { color: #ff9db0; }

.je-editor-footer { display: flex; gap: 10px; margin-top: 4px; }
.je-error, .form-error {
    background: rgba(255,90,110,0.10); border: 1px solid rgba(255,90,110,0.3);
    color: #ff9db0; border-radius: 10px; padding: 9px 12px; font-size: 12.5px; margin: 0;
}
.empty-hint { color: #6b7b8c; font-size: 13px; text-align: center; padding: 30px 10px; }

/* ===================== COA identity / tree ===================== */
.identity-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.identity { display: flex; align-items: center; gap: 13px; }
.account-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(150deg, rgba(20, 184, 166, 0.16), rgba(20, 184, 166, 0.05));
    border: 1px solid rgba(20, 184, 166, 0.24);
    display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0;
}
.account-name { font-weight: 700; font-size: 14.5px; color: #e6edf3; }
.account-code { color: #5f7183; font-size: 12px; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: 0.4px; }

.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 5px 13px; border-radius: 999px; font-weight: 600; flex-shrink: 0; border: 1px solid transparent; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.status-active { background: rgba(45, 212, 191, 0.11); border-color: rgba(45, 212, 191, 0.26); color: #2dd4bf; }
.status-inactive { background: rgba(148, 163, 184, 0.1); border-color: rgba(148, 163, 184, 0.22); color: #94a3b8; }
.status-deprecated { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.24); color: #f87171; }
.status-merged { background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.24); color: #a78bfa; }

.detail-rows { display: flex; flex-direction: column; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 2px; border-bottom: 1px solid #16202b; font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: #6b7b8c; }
.detail-row .value { color: #e6edf3; font-weight: 500; text-align: start; max-width: 62%; }

.tree-list { display: flex; flex-direction: column; }
.node-children { padding-inline-start: 18px; border-inline-start: 1px solid #1a2530; margin-inline-start: 15px; }
.node-row {
    position: relative; display: flex; align-items: center; gap: 10px;
    padding: 10px 13px; border-radius: 10px; cursor: pointer;
    font-size: 13px; margin-bottom: 3px; color: #a9b8c7;
    transition: background 0.14s ease, color 0.14s ease;
}
.node-row:hover { background: rgba(148, 163, 184, 0.07); color: #d6e0ea; }
.node-row.selected { background: rgba(20, 184, 166, 0.11); color: #e6edf3; }
.node-row.selected::before {
    content: ''; position: absolute; inset-inline-start: 0; top: 50%;
    transform: translateY(-50%); width: 3px; height: 58%; border-radius: 3px;
    background: #2dd4bf; box-shadow: 0 0 10px rgba(45, 212, 191, 0.55);
}
.chevron { display: inline-block; width: 12px; font-size: 13px; color: #55677a; transition: transform 0.16s ease; text-align: center; cursor: pointer; }
.chevron.expanded { transform: rotate(-90deg); }
.chevron-spacer { display: inline-block; width: 12px; }
.node-icon { font-size: 13px; opacity: 0.9; }
.node-name { flex: 1; }
.node-row.selected .node-name { font-weight: 600; }
.node-code { font-size: 11px; color: #55677a; font-variant-numeric: tabular-nums; letter-spacing: 0.4px; }
.node-row.selected .node-code { color: #2dd4bf; }

/* ===================== Drawer ===================== */
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(4, 7, 10, 0.68);
    backdrop-filter: blur(2px); display: flex; justify-content: flex-start; z-index: 100;
}
.drawer-panel {
    background: linear-gradient(172deg, #121b24 0%, #0d141b 100%);
    border-inline-end: 1px solid #1e2a36;
    width: min(620px, 94vw); height: 100%;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.65);
    padding: 24px 28px 26px; overflow-y: auto;
    display: flex; flex-direction: column;
}
.drawer-wide { width: min(760px, 96vw); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid #1c2733; }
.drawer-title { font-size: 16px; font-weight: 700; color: #e6edf3; }
.drawer-close { background: transparent; border: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; color: #6b7b8c; }
.drawer-close:hover { background: rgba(148, 163, 184, 0.1); color: #e6edf3; }

.drawer-form { display: flex; flex-direction: column; flex: 1; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-group { margin-bottom: 18px; }
.field-group label { display: block; font-size: 13px; color: #93a3b4; margin-bottom: 8px; }
.field-group input, .field-group textarea, .field-group select {
    width: 100%; min-width: 0; box-sizing: border-box;
    border: 1px solid #24313f; background: rgba(6, 10, 14, 0.55);
    border-radius: 11px; padding: 12px 14px; font-size: 13px;
    font-family: inherit; color: #e6edf3; appearance: none; -webkit-appearance: none;
}
.field-group input::placeholder, .field-group textarea::placeholder { color: #4d5e70; }
.field-group input:disabled { color: #5f7183; background: rgba(6, 10, 14, 0.3); cursor: not-allowed; }
.field-group input:focus, .field-group textarea:focus, .field-group select:focus {
    outline: none; border-color: rgba(20, 184, 166, 0.55); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}
.field-group textarea { min-height: 92px; resize: vertical; }
.field-group select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%232dd4bf' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: left 14px center; padding-left: 36px; cursor: pointer;
}
.field-group option { background: #0e151d; color: #e6edf3; }
.drawer-footer { display: flex; gap: 10px; margin-top: auto; padding-top: 20px; border-top: 1px solid #1c2733; }

/* ===================== Dashboard ===================== */
.hm-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.hm-title { margin: 6px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.hm-links { display: flex; gap: 9px; }
.hm-cta { text-decoration: none; font-size: 13px; font-weight: 600; padding: 9px 15px; border-radius: 10px; background: linear-gradient(180deg, #14b8a6, #0f9c8c); color: #04110f; border: 1px solid transparent; }
.hm-cta.ghost { background: #172230; color: #cdd9e5; border-color: #26333f; }

.hm-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.hm-tile {
    background: linear-gradient(168deg, #131c26 0%, #0e151d 60%, #0d131a 100%);
    border: 1px solid #1e2a36; border-radius: 16px; padding: 16px 18px;
    display: flex; flex-direction: column; gap: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.hm-tile-k { font-size: 12px; color: #8397a8; }
.hm-tile-v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hm-tile-s { font-size: 11px; color: #5f7080; }

.hm-card {
    background: linear-gradient(168deg, #131c26 0%, #0e151d 58%, #0d131a 100%);
    border: 1px solid #1e2a36; border-radius: 18px; padding: 20px 22px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.4); overflow-x: auto;
}
.hm-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.hm-card-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.hm-toggle { font-size: 12px; color: #8fa1b3; display: flex; align-items: center; gap: 7px; cursor: pointer; }
.hm-hint { color: #6b7b8c; font-size: 13px; padding: 24px 6px; }

/* ===================== Toast ===================== */
.toast-wrap { position: fixed; inset-block-start: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
    background: #131c26; border: 1px solid #24313d; border-radius: 10px;
    padding: 11px 15px; font-size: 13px; color: #dbe4ec; max-width: 340px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.toast.err { border-color: rgba(255,90,110,0.4); color: #ff9db0; }
.toast.ok { border-color: #1f8a7e; color: #7fe6d8; }

/* ===================== Responsive ===================== */
@media (max-width: 1100px) { .hm-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1000px) { .coa-page { flex-direction: column; } .je-form-grid { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; }
    .brand { border: none; margin: 0; padding: 0 10px 0 0; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { display: none; }
}
@media (max-width: 560px) { .hm-tiles { grid-template-columns: 1fr; } .field-grid { grid-template-columns: 1fr; } }
