/* =========================================================
   Kontrak Nexus — Design Tokens
   ========================================================= */
:root {
    --navy-950: #0F1B33;
    --navy-900: #16233F;
    --navy-800: #1E2E4D;
    --navy-700: #2A3C5E;

    --bg: #F3F5FA;
    --card: #FFFFFF;

    --accent: #2F8F84;
    --accent-dark: #226B62;
    --accent-soft: #E4F3F1;

    --amber: #E8A33D;
    --amber-dark: #B9791C;
    --amber-soft: #FCF0DC;

    --danger: #E15554;
    --danger-dark: #A93636;
    --danger-soft: #FBE7E6;

    --slate-700: #3B4354;
    --slate-500: #6B7386;
    --slate-400: #9AA2B4;
    --border: #E4E8F0;

    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 27, 51, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 27, 51, 0.08);

    --font-display: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--slate-700);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--navy-950);
    margin: 0 0 4px;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

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

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(185deg, var(--navy-950) 0%, var(--navy-800) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 22px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
}

.brand-text strong {
    display: block;
    font-family: var(--font-display);
    font-size: 15px;
}
.brand-text small {
    color: rgba(255,255,255,0.55);
    font-size: 11.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-md);
    color: rgba(255,255,255,0.72);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
    background: var(--accent);
    color: #fff;
}

.sidebar-alert {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
}
.sidebar-alert.is-warning {
    background: rgba(232, 163, 61, 0.15);
    border-color: rgba(232, 163, 61, 0.35);
}
.sidebar-alert strong { display: block; font-size: 12.5px; }
.sidebar-alert small { color: rgba(255,255,255,0.55); font-size: 11px; }
.alert-badge {
    min-width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--amber);
    color: var(--navy-950);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
}

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title { font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.notif-bell {
    position: relative;
    font-size: 18px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}
.notif-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--card);
}

.user-menu { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--border); }
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-950);
}
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--navy-900);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 13px;
}
.logout-link {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 15px;
    color: var(--slate-500);
}
.logout-link:hover { background: var(--danger-soft); color: var(--danger-dark); border-color: var(--danger-soft); }

.main-content { padding: 28px 32px 40px; flex: 1; }

.app-footer {
    padding: 16px 32px;
    font-size: 12px;
    color: var(--slate-400);
    border-top: 1px solid var(--border);
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 13.5px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-sm { padding: 8px 13px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--slate-700); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn-danger { background: var(--danger-soft); color: var(--danger-dark); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* =========================================================
   Cards / Stat grid
   ========================================================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: 12.5px;
    color: var(--slate-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 30px;
    color: var(--navy-950);
    margin-top: 6px;
}
.stat-card .stat-sub { font-size: 12.5px; color: var(--slate-400); margin-top: 4px; }
.stat-card.accent-amber .stat-value { color: var(--amber-dark); }
.stat-card.accent-danger .stat-value { color: var(--danger-dark); }
.stat-card.accent-teal .stat-value { color: var(--accent-dark); }
.stat-card.accent-muted .stat-value { color: var(--slate-500); }

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.dashboard-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}
.dashboard-split .panel { margin-bottom: 0; min-width: 0; }
@media (max-width: 640px) {
    .dashboard-split { grid-template-columns: minmax(0, 1fr); }
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.panel-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--slate-500); }
.panel-body { padding: 22px; }

/* =========================================================
   Signature element: Expiry Runway
   ========================================================= */
.runway-list { display: flex; flex-direction: column; gap: 14px; }

.runway-item {
    display: grid;
    grid-template-columns: 1fr 130px 60px;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease;
}
.runway-item:hover { border-color: var(--accent); }

.runway-info a { font-weight: 600; color: var(--navy-950); font-size: 14px; }
.runway-info .runway-vendor { display: block; font-size: 12.5px; color: var(--slate-500); margin-top: 2px; }

.runway-track {
    height: 8px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.runway-fill { height: 100%; border-radius: 6px; }

.runway-days {
    text-align: right;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
}
.runway-days small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 10.5px; color: var(--slate-400); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--slate-400);
}
.empty-state .empty-icon { font-size: 30px; margin-bottom: 8px; display: block; }

/* =========================================================
   Badges
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-success { background: var(--accent-soft); color: var(--accent-dark); }
.badge-warning { background: var(--amber-soft); color: var(--amber-dark); }
.badge-danger  { background: var(--danger-soft); color: var(--danger-dark); }
.badge-muted   { background: var(--bg); color: var(--slate-500); border: 1px solid var(--border); }

/* =========================================================
   Tables
   ========================================================= */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--slate-500);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg); }
.cell-title { font-weight: 600; color: var(--navy-950); }
.cell-sub { font-size: 12px; color: var(--slate-500); }
.row-actions { display: flex; gap: 8px; }
.row-actions a, .row-actions button {
    font-size: 12.5px;
    padding: 6px 10px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
}
.row-actions a:hover { border-color: var(--accent); color: var(--accent-dark); }

/* =========================================================
   Forms
   ========================================================= */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-950);
    margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--slate-400); margin-top: 5px; }

.field input[type=text],
.field input[type=date],
.field input[type=number],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 13.5px;
    background: var(--card);
    color: var(--slate-700);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 80px; }

.status-toggle { display: flex; gap: 10px; }
.status-toggle label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
}
.status-toggle input { display: none; }
.status-toggle input:checked + span { color: var(--accent-dark); }
.status-toggle label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.alert-flash {
    padding: 13px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    margin-bottom: 20px;
    font-weight: 500;
}
.alert-flash.success { background: var(--accent-soft); color: var(--accent-dark); }
.alert-flash.error { background: var(--danger-soft); color: var(--danger-dark); }

/* =========================================================
   Calendar page
   ========================================================= */
.calendar-legend { display: flex; gap: 18px; margin-bottom: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--slate-500); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

#calendar { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); }

.fc { font-family: var(--font-body); }
.fc .fc-toolbar-title { font-family: var(--font-display); font-size: 18px; color: var(--navy-950); }
.fc .fc-button-primary {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--slate-700);
    box-shadow: none;
    text-transform: capitalize;
    font-weight: 600;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.fc-daygrid-event { border: none; padding: 3px 6px; font-size: 11.5px; font-weight: 600; }
.fc-day-today { background: var(--accent-soft) !important; }

.evt-block { line-height: 1.25; overflow: hidden; }
.evt-title {
    font-weight: 700;
    font-size: 11.5px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.evt-period {
    font-weight: 500;
    font-size: 10px;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,27,51,0.55);
    display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--card); border-radius: var(--radius-lg); width: 420px; max-width: 100%;
    padding: 24px; box-shadow: var(--shadow-md);
}
.modal-box h3 { margin-bottom: 10px; }
.modal-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.modal-row span:first-child { color: var(--slate-500); }
.modal-row span:last-child { font-weight: 600; color: var(--navy-950); text-align: right; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-close { position: absolute; }

/* =========================================================
   Login page (glass card + floating balls)
   ========================================================= */
.login-body {
    background: radial-gradient(circle at top left, var(--navy-800), var(--navy-950) 65%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
    position: relative;
}

/* Decorative floating balls behind the glass card */
.ball {
    position: fixed;
    border-radius: 50%;
    filter: blur(2px);
    pointer-events: none;
    z-index: 0;
    animation: floatBall 9s ease-in-out infinite;
}
@keyframes floatBall {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(14px, -22px); }
}
.ball-1 { width: 160px; height: 160px; top: 8%;  left: 10%; background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%); opacity: 0.35; animation-duration: 10s; }
.ball-2 { width: 110px; height: 110px; top: 15%; right: 12%; background: radial-gradient(circle at 30% 30%, var(--amber), transparent 70%); opacity: 0.3; animation-duration: 8s; animation-delay: .5s; }
.ball-3 { width: 200px; height: 200px; bottom: 6%; left: 6%; background: radial-gradient(circle at 30% 30%, var(--navy-700), transparent 70%); opacity: 0.5; animation-duration: 12s; animation-delay: 1s; }
.ball-4 { width: 130px; height: 130px; bottom: 10%; right: 10%; background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%); opacity: 0.3; animation-duration: 9s; animation-delay: 1.5s; }
.ball-5 { width: 70px;  height: 70px;  top: 42%; left: 4%;  background: radial-gradient(circle at 30% 30%, var(--amber), transparent 70%); opacity: 0.25; animation-duration: 7s; animation-delay: .8s; }
.ball-6 { width: 90px;  height: 90px;  top: 55%; right: 6%; background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%); opacity: 0.25; animation-duration: 11s; animation-delay: .3s; }
.ball-7 { width: 50px;  height: 50px;  top: 5%;  left: 45%; background: radial-gradient(circle at 30% 30%, var(--amber), transparent 70%); opacity: 0.3; animation-duration: 6.5s; animation-delay: 1.2s; }

.glass-circle {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 28px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 42px 34px 30px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.login-form { display: flex; flex-direction: column; }
.login-form h1 {
    text-align: center;
    font-family: var(--font-display);
    font-size: 25px;
    color: #fff;
    margin: 0 0 4px;
}
.login-form .login-subtitle {
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.62);
    margin: 0 0 24px;
}

.input-box { position: relative; margin-bottom: 16px; }
.input-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.55);
    font-size: 18px;
}
.input-box input {
    width: 100%;
    padding: 13px 14px 13px 44px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-family: var(--font-body);
    font-size: 14px;
}
.input-box input::placeholder { color: rgba(255,255,255,0.45); }
.input-box input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255,255,255,0.12);
}

.forgot { text-align: right; margin: -4px 0 20px; }
.forgot a { font-size: 12.5px; color: rgba(255,255,255,0.55); }
.forgot a:hover { color: #fff; }

.login-form button[type="submit"] {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 14.5px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.login-form button[type="submit"]:hover { background: var(--accent-dark); }

.alert-error {
    background: rgba(225, 85, 84, 0.18);
    border: 1px solid rgba(225, 85, 84, 0.35);
    color: #ffd6d5;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
    text-align: center;
    backdrop-filter: blur(5px);
}

.hint {
    font-size: 11.5px;
    color: rgba(255,255,255,0.5);
    margin-top: 18px;
    text-align: center;
}
