:root {
    --green: #123d2a;
    --green-2: #2f7d4f;
    --green-3: #dff0e2;
    --cream: #f6f0df;
    --card: #fffdf7;
    --border: #dfd0a8;
    --text: #243127;
    --muted: #6f766f;
    --warning: #9a6700;
    --warning-bg: #fff2c6;
    --danger: #9c2b22;
    --danger-bg: #fde4df;
    --shadow: 0 10px 28px rgba(32, 58, 42, .09);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0;
    color: var(--text);
    font-family: Tahoma, Arial, sans-serif;
    background: radial-gradient(circle at top left, rgba(47,125,79,.13), transparent 28%), linear-gradient(135deg,#fbf7ea,#f0e6cd);
    min-height: 100vh;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
.app-header {
    min-height: 72px;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: #fff8e7;
    background: var(--green);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 8px 25px rgba(18,61,42,.18);
}
.brand-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
    width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
    color: var(--green); background: #fff8e7; font-size: 24px; font-weight: 950;
}
.brand-title { font-weight: 950; letter-spacing: .4px; font-size: 18px; }
.brand-sub { font-size: 11px; opacity: .8; margin-top: 3px; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; }
.header-user form { margin: 0; }
.app-shell { max-width: 1450px; margin: 0 auto; display: grid; grid-template-columns: 235px minmax(0,1fr); min-height: calc(100vh - 72px); }
.app-shell.auth-shell { display: block; max-width: 620px; min-height: auto; }
.sidebar { padding: 18px 12px; border-right: 1px solid rgba(126,105,60,.18); }
.nav-item {
    display: block; padding: 11px 12px; margin-bottom: 7px; border-radius: 12px; text-decoration: none;
    font-weight: 850; color: var(--green);
}
.nav-item:hover, .nav-item.active { background: var(--green-2); color: white; }
.sidebar-note { margin-top: 22px; padding: 13px; border-radius: 14px; background: rgba(255,255,255,.52); color: var(--muted); font-size: 11px; line-height: 1.6; }
.content { padding: 22px; min-width: 0; }
.page-title { margin: 0; font-size: 27px; color: var(--green); font-weight: 950; }
.page-sub { margin: 6px 0 18px; color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 10px; margin-bottom: 15px; }
.summary-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 15px; box-shadow: var(--shadow); min-height: 102px; }
.summary-label { font-size: 11px; font-weight: 800; color: var(--muted); }
.summary-value { margin-top: 8px; font-size: 28px; font-weight: 950; color: var(--green); line-height: 1; }
.summary-card.warning .summary-value { color: var(--warning); }
.summary-card.danger .summary-value { color: var(--danger); }
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }
.form-control, .form-select {
    width: 100%; padding: 10px 11px; border: 1px solid #d9c99f; border-radius: 11px; background: white; color: var(--text); outline: none;
}
.form-control:focus, .form-select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(47,125,79,.12); }
label { display: block; margin-bottom: 6px; font-weight: 850; font-size: 12px; color: #33483a; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
textarea.form-control { min-height: 100px; resize: vertical; }
.validation { color: var(--danger); font-size: 11px; margin-top: 4px; }
.validation-summary-errors { color: var(--danger); background: var(--danger-bg); border: 1px solid #e7aba4; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; }
.btn { border: 0; border-radius: 11px; padding: 10px 13px; font-weight: 900; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn-primary { background: var(--green-2); color: white; }
.btn-dark { background: var(--green); color: white; }
.btn-warning { background: #e6b440; color: #4f3900; }
.btn-danger { background: #bb4438; color: white; }
.btn-light { background: #fff; color: var(--green); border: 1px solid var(--border); }
.btn-outline-light { background: transparent; color: white; border: 1px solid rgba(255,255,255,.45); }
.btn-sm { padding: 7px 9px; font-size: 11px; }
.alert { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-weight: 800; line-height: 1.5; }
.alert.success { background: #dff2df; color: #245a31; border: 1px solid #a8d3ad; }
.alert.warning { background: var(--warning-bg); color: #705000; border: 1px solid #e4c662; }
.alert.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #e3a69e; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { text-align: left; font-size: 11px; color: var(--muted); padding: 9px 8px; border-bottom: 1px solid #d8cca9; white-space: nowrap; }
td { padding: 11px 8px; border-bottom: 1px solid #eee4ca; vertical-align: top; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.client-name { font-weight: 950; color: var(--green); font-size: 13px; }
.muted { color: var(--muted); font-size: 11px; }
.status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 950; white-space: nowrap; }
.status.ACTIVE { background: #dff2df; color: #246234; }
.status.EXPIRING { background: #fff0bc; color: #7a5700; }
.status.GRACE { background: #ffe0a8; color: #794900; }
.status.EXPIRED, .status.SUSPENDED { background: #f8d7d1; color: #92281f; }
.detail-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.detail-item { background: #fff; border: 1px solid #e6dcc0; border-radius: 14px; padding: 12px; min-height: 82px; }
.detail-label { color: var(--muted); font-size: 10px; font-weight: 850; }
.detail-value { margin-top: 6px; color: var(--green); font-size: 15px; font-weight: 950; word-break: break-word; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.key-box { background: #13281d; color: #e8f7e9; padding: 14px; border-radius: 14px; word-break: break-all; font-family: Consolas, monospace; font-size: 13px; }
.code-box { width: 100%; min-height: 150px; background: #1c2821; color: #e8f7e9; border: 0; border-radius: 14px; padding: 13px; font-family: Consolas, monospace; resize: vertical; }
.auth-card { margin: 48px auto; max-width: 520px; }
.auth-card .page-title { font-size: 24px; }
.mobile-nav { display: none; }
.empty { text-align: center; padding: 35px 15px; color: var(--muted); }
.section-title { font-size: 16px; font-weight: 950; color: var(--green); margin: 0 0 12px; }
.inline-note { padding: 10px 12px; background: rgba(47,125,79,.08); color: #3e5b47; border-radius: 11px; font-size: 11px; line-height: 1.55; }
@media (max-width: 1150px) {
    .summary-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
    .app-header { min-height: 64px; padding: 10px 12px; }
    .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 20px; }
    .brand-title { font-size: 14px; }
    .brand-sub { font-size: 9px; }
    .header-user > span { display: none; }
    .app-shell { display: block; min-height: calc(100vh - 112px); }
    .sidebar { display: none; }
    .mobile-nav { display: grid; grid-template-columns: repeat(3,1fr); position: sticky; top: 64px; z-index: 45; background: #fffaf0; border-bottom: 1px solid var(--border); }
    .mobile-nav a { padding: 10px 5px; text-align: center; text-decoration: none; font-size: 10px; font-weight: 900; color: var(--green); }
    .mobile-nav a.active { background: var(--green-3); }
    .content { padding: 12px; }
    .page-title { font-size: 22px; }
    .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .summary-card { min-height: 90px; padding: 12px; }
    .summary-value { font-size: 24px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .detail-item { padding: 10px; min-height: 72px; }
    .detail-value { font-size: 13px; }
    .auth-card { margin: 24px auto; }
}
@media (max-width: 430px) {
    .detail-grid { grid-template-columns: 1fr; }
    .action-row .btn { flex: 1 1 auto; }
}
