/* =====================================================================
   T-SYSTEM :: Premium dark admin theme
   Graphite background · metallic silver panels · red accent
   ===================================================================== */

:root {
    --bg:            #0b0d10;
    --bg-2:          #0f1216;
    --panel:         #14181e;
    --panel-2:       #191e26;
    --panel-hi:      #1f2530;
    --stroke:        #262c36;
    --stroke-2:      #333b48;
    --silver:        #c7ced8;
    --silver-2:      #8b93a1;
    --muted:         #6b7382;
    --text:          #e7ebf1;
    --text-dim:      #aab2c0;
    --red:           #e01e2b;
    --red-2:         #ff3b48;
    --red-soft:      rgba(224, 30, 43, .12);
    --green:         #21c07a;
    --amber:         #f4b13e;
    --blue:          #4c8dff;
    --radius:        14px;
    --radius-sm:     10px;
    --shadow:        0 10px 30px rgba(0,0,0,.45);
    --shadow-sm:     0 4px 14px rgba(0,0,0,.35);
    --sidebar-w:     264px;
    --header-h:      64px;
    --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: radial-gradient(1200px 600px at 80% -10%, #12161d 0%, var(--bg) 55%) fixed;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
::selection { background: var(--red); color: #fff; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a313c; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3a4350; }

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

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #12161c 0%, #0d1015 100%);
    border-right: 1px solid var(--stroke);
    position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column;
    z-index: 60;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex; flex-direction: column;
}

/* ---------------------------------------------------------------- Brand */
.brand {
    height: var(--header-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--stroke);
}
.brand-logo {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    display: grid; place-items: center;
    font-weight: 800; font-size: 18px; color: #fff;
    background: linear-gradient(135deg, var(--red) 0%, #8f0f18 100%);
    box-shadow: 0 4px 14px rgba(224,30,43,.4), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-name { font-weight: 800; letter-spacing: .5px; font-size: 16px; }
.brand-name span { color: var(--red-2); }
.brand-sub { font-size: 10px; letter-spacing: 2px; color: var(--silver-2); text-transform: uppercase; }

/* ---------------------------------------------------------------- Nav */
.nav { flex: 1; overflow-y: auto; padding: 14px 12px 30px; }
.nav-group-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px;
    color: var(--muted); padding: 16px 12px 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-dim); font-weight: 500;
    transition: background .15s, color .15s; cursor: pointer;
    position: relative;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
    background: linear-gradient(90deg, var(--red-soft), transparent);
    color: #fff;
}
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
    width: 3px; border-radius: 3px; background: var(--red);
}
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-sub { margin: 2px 0 4px 14px; padding-left: 8px; border-left: 1px solid var(--stroke); }
.nav-sub .nav-item { padding: 8px 12px; font-size: 13px; }
.nav-badge {
    margin-left: auto; font-size: 11px; background: var(--panel-hi);
    color: var(--silver); padding: 1px 8px; border-radius: 20px;
}

/* ---------------------------------------------------------------- Header */
.header {
    height: var(--header-h); position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 16px;
    padding: 0 24px;
    background: rgba(13,16,21,.78);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--stroke);
}
.header h1 { font-size: 18px; margin: 0; }
.hamburger { display: none; background: none; border: 0; color: var(--text); cursor: pointer; }
.search {
    margin-left: auto; position: relative; width: min(340px, 40vw);
}
.search input {
    width: 100%; height: 40px; padding: 0 14px 0 40px;
    background: var(--panel); border: 1px solid var(--stroke); border-radius: 22px;
    color: var(--text); outline: none; transition: border .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.search svg { position: absolute; left: 14px; top: 11px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center;
    border-radius: 12px; background: var(--panel); border: 1px solid var(--stroke);
    color: var(--text-dim); cursor: pointer; position: relative; transition: .15s;
}
.icon-btn:hover { color: #fff; border-color: var(--stroke-2); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--panel); }
.chip-user { display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 6px; border-radius: 30px; background: var(--panel); border: 1px solid var(--stroke); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg,#3a4150,#222933); font-size: 13px; }
.chip-user .u-name { font-weight: 600; font-size: 13px; }
.chip-user .u-role { font-size: 11px; color: var(--silver-2); }

/* ---------------------------------------------------------------- Content */
.content { padding: 26px 24px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--silver-2); font-size: 13px; }
.spacer { margin-left: auto; }

/* ---------------------------------------------------------------- Badges & roles */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; border: 1px solid transparent; }
.badge-success { background: rgba(33,192,122,.14); color: #4bd99a; border-color: rgba(33,192,122,.25); }
.badge-info    { background: rgba(76,141,255,.14); color: #7fb0ff; border-color: rgba(76,141,255,.25); }
.badge-warning { background: rgba(244,177,62,.14); color: #f6c368; border-color: rgba(244,177,62,.25); }
.badge-danger  { background: var(--red-soft); color: var(--red-2); border-color: rgba(224,30,43,.3); }
.badge-muted   { background: #21262f; color: var(--silver-2); border-color: var(--stroke); }
.role-pill { font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 4px 10px; border-radius: 8px; text-transform: uppercase; background: linear-gradient(135deg,#2a3140,#20262f); color: var(--silver); border: 1px solid var(--stroke-2); }

/* ---------------------------------------------------------------- Cards */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.card {
    background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--stroke); }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .spacer { margin-left: auto; }

.stat {
    position: relative; overflow: hidden;
    padding: 18px 20px;
    display: flex; flex-direction: column; gap: 8px;
}
.stat .label { color: var(--silver-2); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.stat .foot { font-size: 12px; color: var(--muted); }
.stat .stat-ico {
    position: absolute; right: 16px; top: 16px;
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #232a35, #1a2029);
    border: 1px solid var(--stroke-2);
}
.stat.accent .stat-ico { background: linear-gradient(135deg, var(--red), #7f0e16); border-color: transparent; box-shadow: 0 6px 16px rgba(224,30,43,.35); }
.stat::after { content:''; position:absolute; left:0; right:0; bottom:0; height:3px; background: linear-gradient(90deg, var(--red), transparent); opacity:.5; }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; white-space: nowrap; }
table.data thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
    color: var(--silver-2); background: var(--panel); border-bottom: 1px solid var(--stroke); font-weight: 600;
}
table.data tbody tr { border-bottom: 1px solid var(--stroke); transition: background .12s; }
table.data tbody tr:hover { background: var(--panel-hi); }
table.data tbody tr:last-child { border-bottom: 0; }
.mono { font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
.key-chip { display:inline-flex; align-items:center; gap:8px; background: var(--bg-2); border:1px solid var(--stroke); border-radius:8px; padding:4px 8px; }
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 18px; border-radius: 11px; cursor: pointer;
    font-weight: 600; font-size: 13.5px; border: 1px solid var(--stroke-2);
    background: var(--panel-2); color: var(--text); transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--silver-2); background: var(--panel-hi); }
.btn-primary { background: linear-gradient(135deg, var(--red) 0%, #b5121d 100%); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(224,30,43,.35); }
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--red-2) 0%, var(--red) 100%); }
.btn-ghost { background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 9px; }
.btn-danger { color: var(--red-2); border-color: rgba(224,30,43,.3); }
.btn-danger:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: inline-flex; gap: 6px; }

/* ---------------------------------------------------------------- Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.col-span { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
label .req { color: var(--red-2); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; height: 44px; padding: 0 14px;
    background: var(--bg-2); border: 1px solid var(--stroke); border-radius: 11px;
    color: var(--text); outline: none; font-family: inherit; font-size: 14px;
    transition: border .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a1' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.hint { font-size: 11.5px; color: var(--muted); }
.checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--red); }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }

/* Segmented duration options */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); gap: 10px; }
.opt {
    display: block; text-align: center; padding: 12px 8px; border-radius: 11px; cursor: pointer;
    background: var(--bg-2); border: 1px solid var(--stroke); font-weight: 600; transition: .15s; user-select: none;
}
.opt input { display: none; }
.opt:hover { border-color: var(--stroke-2); }
.opt.selected { border-color: var(--red); background: var(--red-soft); color: #fff; box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------------------------------------------------------------- Flash / alerts */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: rgba(33,192,122,.1); border-color: rgba(33,192,122,.3); color: #7de3b3; }
.alert-error { background: var(--red-soft); border-color: rgba(224,30,43,.35); color: #ff9098; }
.alert-info { background: rgba(76,141,255,.1); border-color: rgba(76,141,255,.3); color: #9dc0ff; }

/* ---------------------------------------------------------------- Pagination */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 36px; height: 36px; padding: 0 10px; display: grid; place-items: center;
    border-radius: 9px; border: 1px solid var(--stroke); background: var(--panel); color: var(--text-dim); font-size: 13px;
}
.pagination a:hover { border-color: var(--stroke-2); color: #fff; }
.pagination .current { background: var(--red); border-color: transparent; color: #fff; }
.pagination .disabled { opacity: .4; }

/* ---------------------------------------------------------------- Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar input, .toolbar select { height: 40px; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--stroke); border-radius: 12px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 9px; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.tabs a.active { background: var(--panel-hi); color: #fff; }
.tabs a:hover { color: #fff; }

/* ---------------------------------------------------------------- Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,6,9,.7); backdrop-filter: blur(4px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { width: min(440px, 100%); background: var(--panel-2); border: 1px solid var(--stroke-2); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--stroke); font-weight: 700; }
.modal-body { padding: 20px; color: var(--text-dim); }
.modal-foot { padding: 16px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--stroke); }

/* ---------------------------------------------------------------- Charts */
.chart { width: 100%; height: 240px; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--silver-2); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ---------------------------------------------------------------- Hierarchy tree */
.tree ul { list-style: none; margin: 0; padding-left: 26px; position: relative; }
.tree > ul { padding-left: 0; }
.tree li { position: relative; padding: 6px 0; }
.tree ul ul li::before { content: ''; position: absolute; top: -6px; left: -14px; border-left: 1px solid var(--stroke-2); border-bottom: 1px solid var(--stroke-2); width: 14px; height: 26px; border-bottom-left-radius: 8px; }
.tree ul ul li::after { content: ''; position: absolute; top: 20px; bottom: -6px; left: -14px; border-left: 1px solid var(--stroke-2); }
.tree ul ul li:last-child::after { display: none; }
.node {
    display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px;
    background: linear-gradient(180deg,var(--panel-2),var(--panel)); border: 1px solid var(--stroke);
    border-radius: 12px; cursor: pointer; transition: .15s;
}
.node:hover { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.node .n-role { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; }
.node .n-name { font-weight: 650; }
.node .n-meta { font-size: 11.5px; color: var(--silver-2); }
.node .caret { color: var(--muted); transition: transform .15s; }
.node.collapsed .caret { transform: rotate(-90deg); }
.tree li.hide-children > ul { display: none; }

/* Role colour dots (1..6) */
.rc1 { background: linear-gradient(135deg,#e01e2b,#8f0f18); }
.rc2 { background: linear-gradient(135deg,#f4b13e,#a9741d); }
.rc3 { background: linear-gradient(135deg,#4c8dff,#274d99); }
.rc4 { background: linear-gradient(135deg,#21c07a,#127048); }
.rc5 { background: linear-gradient(135deg,#9d6bff,#5a2f9e); }
.rc6 { background: linear-gradient(135deg,#8b93a1,#565d69); }

/* ---------------------------------------------------------------- Misc */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { opacity: .4; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; }
.kv .k { color: var(--silver-2); font-size: 13px; }
.kv .v { font-weight: 500; }
.divider { height: 1px; background: var(--stroke); margin: 20px 0; }
.flex { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.mt { margin-top: 18px; } .mb { margin-bottom: 18px; }
.text-red { color: var(--red-2); } .text-green { color: var(--green); } .text-amber { color: var(--amber); }
.big-num { font-size: 20px; font-weight: 750; }

/* ---------------------------------------------------------------- Chat / complaints */
.chat-thread { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; max-height: 540px; overflow-y: auto; }
.bubble { max-width: 74%; padding: 10px 14px; border-radius: 14px; background: var(--panel-hi); border: 1px solid var(--stroke); }
.bubble .meta { font-size: 11px; color: var(--silver-2); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.bubble .text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, #2a1416, #37191c); border-color: rgba(224,30,43,.35); }
.bubble.them { align-self: flex-start; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 16px; }
.chat-form textarea { min-height: 46px; }

/* Mobile bottom nav */
.bottom-nav { display: none; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 900px) {
    .cols-3 { grid-template-columns: repeat(2,1fr); }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: grid; place-items: center; }
    .search { width: auto; flex: 1; }
    .content { padding: 18px 14px 90px; }
    .chip-user .u-meta { display: none; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 55; display: none; }
    .sidebar-overlay.open { display: block; }
    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
        background: rgba(13,16,21,.95); backdrop-filter: blur(10px);
        border-top: 1px solid var(--stroke); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
        justify-content: space-around;
    }
    .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--text-dim); padding: 4px 10px; border-radius: 10px; }
    .bottom-nav a.active { color: var(--red-2); }
}
@media (max-width: 560px) {
    .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 19px; }
    .header h1 { display: none; }
}
