/* Rova Security — navy brand on AdminLTE */
:root { --rova-navy: #00264d; --rova-deep: #001a33; --rova-blue: #004080; }
.main-sidebar { background-color: var(--rova-deep) !important; }
.brand-link { background-color: var(--rova-navy) !important; }
.brand-link .brand-text { color: #fff !important; font-weight: 600 !important; }
.nav-sidebar .nav-link.active { background-color: var(--rova-blue) !important; color: #fff !important; }
.nav-sidebar .nav-header { font-size: .7rem; letter-spacing: .06em; color: #7f93a8 !important; padding-top: .9rem; }
.btn-primary { background-color: var(--rova-blue); border-color: var(--rova-blue); }
.btn-primary:hover { background-color: var(--rova-navy); border-color: var(--rova-navy); }
.content-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-actions .btn, .page-actions form { margin-left: .25rem; margin-bottom: .25rem; }
.card-title { font-weight: 600; }
.table td, .table th { vertical-align: middle; }
.table-sm td, .table-sm th { padding: .35rem .5rem; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi .small-box h3 { font-size: 1.7rem; }
.kpi .small-box p { margin-bottom: .2rem; }
.muted-note { font-size: .82rem; color: #6c757d; }
.required:after { content: " *"; color: #dc3545; }
.nowrap { white-space: nowrap; }
.select2-container { width: 100% !important; }
/* payroll grid */
.grid-wrap { overflow: auto; max-height: 72vh; }
.grid-wrap table { font-size: .8rem; }
.grid-wrap thead th { position: sticky; top: 0; background: #f4f6f9; z-index: 2; }
.grid-wrap td.sticky, .grid-wrap th.sticky { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 170px; }
.grid-wrap thead th.sticky { z-index: 3; background: #f4f6f9; }
.grid-wrap input.g { width: 78px; padding: 1px 4px; height: 26px; font-size: .8rem; text-align: right; }
.grid-wrap input.g.days { width: 52px; }
.grid-wrap tr.changed td { background: #fff8e1; }
.grid-wrap td.net { font-weight: 700; }
.grid-wrap tfoot td { position: sticky; bottom: 0; background: #e9ecef; font-weight: 700; }
/* A label on the left and its value on the right. When the value is long
   enough to wrap — a payroll name followed by a status badge, say — the
   wrapped part has to stay against the right edge with everything else,
   rather than starting back in the middle of the row. */
.stat-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  border-bottom: 1px dashed #e3e6ea; padding: .3rem 0;
}
.stat-line > :first-child { flex: 1 1 auto; min-width: 0; }
/* Only when there are two sides to the row: a row with a single block of text
   (the setup checklist) must stay left-aligned like ordinary prose. */
.stat-line > :last-child:not(:first-child) { flex: 0 1 auto; min-width: 0; text-align: right; }
.stat-line:last-child { border-bottom: 0; }
@media (max-width: 576px) { .content-header h1 { font-size: 1.25rem; } }

/* Keyboard users must be able to see where they are. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, .nav-link:focus-visible {
  outline: 3px solid #ffb703;
  outline-offset: 1px;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--rova-navy); color: #fff; padding: 10px 16px; border-radius: 0 0 4px 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* Tables scroll inside their own card rather than dragging the page sideways.
   The fade on the right edge says there is more to see. */
.table-responsive { -webkit-overflow-scrolling: touch; }
/* The "there is more to the right" fade is painted as a background, not as a
   floated element: a float sits in the flow and pushed the last cell of the
   last row 24px off the edge everything else lined up to. */
.table-responsive.is-scrollable {
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, .10));
  background-position: right center;
  background-size: 22px 100%;
  background-repeat: no-repeat;
  background-attachment: local;
}
.table-responsive.is-scrollable.at-end { background-image: none; }
@media (max-width: 575.98px) {
  .content-header h1 { font-size: 1.15rem; }
  .page-actions .btn { font-size: .8rem; }
  .info-box { margin-bottom: .6rem; }
  .card-header .form-inline .form-control { margin-bottom: .3rem; }
}
/* On a narrow screen a stat label should wrap rather than be cut off. */
@media (max-width: 767.98px) {
  /* AdminLTE truncates these with an ellipsis; on a phone the label matters
     more than the single line, so let it wrap. Selector matches theirs so it
     actually wins. */
  .info-box .info-box-content .info-box-text,
  .info-box .info-box-content .info-box-number {
    white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25;
  }
  .info-box { min-height: 76px; }
  .info-box .info-box-content .info-box-number { font-size: 1rem; }
}

.client-picker { min-width: 320px; }
@media (max-width: 767.98px) { .client-picker { min-width: 0; width: 100%; } }

/* ---------------------------------------------------------------------------
   Small screens: a row becomes a labelled block, so everything on it can be
   read straight down the page with no sideways scrolling.
   --------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  table.stackable, table.stackable > tbody, table.stackable > tbody > tr, table.stackable > tbody > tr > td {
    display: block; width: 100%;
  }
  table.stackable > thead { display: none; }
  table.stackable > tbody > tr {
    border: 1px solid #dfe3e8; border-radius: 5px; background: #fff;
    margin: 0 0 .5rem; padding: .4rem .6rem;
  }
  table.stackable.table-striped > tbody > tr:nth-of-type(odd) { background: #fbfcfd; }
  table.stackable > tbody > tr > td {
    border: 0; padding: .22rem 0; text-align: left !important;
    display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
    /* a long email, reference or note has to be allowed to wrap, or it pushes
       the card wider than the screen on its own */
    min-width: 0; overflow-wrap: anywhere; word-break: break-word;
  }
  table.stackable > tbody > tr > td:before {
    content: attr(data-label); color: #6c757d; font-size: .78rem; font-weight: 600;
    flex: 0 0 42%; text-transform: none;
  }
  table.stackable > tbody > tr > td[data-label=""]:before,
  table.stackable > tbody > tr > td:not([data-label]):before { content: none; }
  /* the first cell is the thing itself: give it the top line, no label */
  table.stackable > tbody > tr > td:first-child {
    font-weight: 600; font-size: .95rem; border-bottom: 1px dashed #e9edf1;
    margin-bottom: .2rem; padding-bottom: .3rem; display: block;
    overflow-wrap: anywhere; word-break: break-word;
  }
  table.stackable { width: 100% !important; table-layout: auto !important; }
  table.stackable > tbody > tr > td .muted-note { word-break: break-word; }
  /* a wide control inside a cell must not set the width of the card */
  table.stackable input, table.stackable select, table.stackable .form-control { max-width: 100%; min-width: 0 !important; }
  table.stackable > tbody > tr > td:first-child:before { content: none; }
  /* an empty cell would only show an orphaned label */
  table.stackable > tbody > tr > td:empty { display: none; }
  /* The theme pads the first and last cell of a table inside a card by 1.5rem
     to line the columns up with the card edge. Folded, that padding pushes the
     last value (usually a status badge) in from the edge everything else lines
     up to, so take it off. */
  table.stackable > tbody > tr > td:first-child,
  table.stackable > tbody > tr > td:last-child { padding-left: 0 !important; padding-right: 0 !important; }
  /* A cell with no heading of its own is the actions cell: keep its buttons
     together at the end rather than pushed to opposite edges. */
  table.stackable > tbody > tr > td[data-label=""],
  table.stackable > tbody > tr > td:not([data-label]) { justify-content: flex-end; gap: .4rem; }
  table.stackable > tbody > tr > td.nowrap { white-space: normal; }
  table.stackable > tbody > tr > td .btn { margin: .1rem 0 .1rem .25rem; }
  table.stackable > tfoot { display: block; }
  table.stackable > tfoot > tr { display: flex; flex-wrap: wrap; gap: .5rem; padding: .4rem .6rem; }
  table.stackable > tfoot > tr > td, table.stackable > tfoot > tr > th { border: 0; padding: .1rem .3rem; }
  /* the daily register keeps its choices on one line instead of five rows */
  table.stack-inline > tbody > tr > td.choice {
    display: inline-flex; width: auto; flex: 0 0 auto; gap: .3rem; margin-right: .7rem; padding: .3rem 0;
  }
  table.stack-inline > tbody > tr > td.choice:before { flex: 0 0 auto; font-size: .8rem; }
  /* DataTables furniture needs room to breathe */
  .dataTables_wrapper .row > div { padding-left: .5rem; padding-right: .5rem; }
  .dataTables_length, .dataTables_filter { text-align: left !important; }
  .dataTables_filter input { width: 100%; margin-left: 0 !important; }
  .dataTables_paginate { float: none !important; text-align: center; }
  .dataTables_info { text-align: center; padding-top: .4rem; }
  /* DataTables tells the pager never to wrap and to centre itself, so anything
     wider than the card spills off both edges at once. Let it wrap instead, so
     no screen width or text size can push a button outside the card. */
  div.dataTables_wrapper div.dataTables_paginate { white-space: normal; max-width: 100%; }
  div.dataTables_wrapper div.dataTables_paginate ul.pagination {
    flex-wrap: wrap; justify-content: center !important; row-gap: .35rem; margin: .5rem 0 0;
  }
}

/* A note written under a table belongs to the table, but it must not sit on
   the pager: give whatever follows a table's controls some room. */
.dataTables_wrapper + * { margin-top: .75rem !important; }

.grid-hint {
  display: none; background: #fff8e1; border: 1px solid #ffe6a1; color: #7a5a00;
  font-size: .82rem; padding: .5rem .7rem; margin: .5rem; border-radius: 4px;
}
@media (max-width: 767.98px) { .grid-hint { display: block; } }

/* ---------------------------------------------------------------------------
   Boxes in a row are all as tall as the tallest, so an extra line of text in
   one does not leave its neighbours short.
   --------------------------------------------------------------------------- */
.equal-box { display: flex; }
.equal-box > .small-box, .equal-box > .info-box { width: 100%; }
.equal-box > .small-box { display: flex; flex-direction: column; }
.equal-box > .small-box .inner { flex: 1 1 auto; }
.equal-box > .small-box .small-box-footer { margin-top: auto; }

@media (max-width: 575.98px) {
  /* On a phone the figure matters more than the picture beside it. */
  .info-box .info-box-icon { width: 46px; font-size: 1.1rem; }
  .info-box .info-box-content { margin-left: 0; padding: .4rem .5rem; }
  .info-box .info-box-content .info-box-number { font-size: .95rem; }
  .small-box .inner h3 { font-size: 1.6rem; }
  .small-box .icon { display: none; }          /* the watermark eats the text at this width */
  .small-box .inner p { margin-bottom: .25rem; }
}

/* ---------------------------------------------------------------------------
   Filter and toolbar rows. On a narrow screen these wrap, and Bootstrap's
   inline form gives no room between the pieces once they do — controls end up
   touching each other and running past the card edge. Space them with a gap
   and let each one take a sensible width.
   --------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .form-inline {
    flex-wrap: wrap;
    align-items: center;
    row-gap: .5rem;
    column-gap: .5rem;
  }
  /* the gap does the spacing now, so the helper margins would double it */
  .form-inline > *,
  .form-inline > .form-control,
  .form-inline > .btn { margin: 0 !important; }

  .form-inline > .form-control,
  .form-inline > div:not(.custom-control):not(.input-group) { flex: 1 1 150px; min-width: 0; max-width: 100%; }
  .form-inline > .form-control[type="date"],
  .form-inline > .form-control[type="month"] { flex: 1 1 150px; }
  .form-inline > .form-control[type="number"] { flex: 0 1 110px; }
  .form-inline > label { flex: 0 0 auto; margin: 0 !important; }
  .form-inline > .btn { flex: 0 0 auto; }
  .form-inline .select2-container { min-width: 0; }

  /* buttons that belong together stay together */
  .card-header .form-inline + div,
  .card-header > div > .btn { margin-top: .25rem; }
  .card-header { padding: .6rem .75rem; }
}

/* The register's own toolbar: the day arrows belong to the date, the site
   picker takes the width it needs, and the two actions sit side by side. */
.reg-toolbar .day-picker { width: auto; flex: 0 0 auto; }
.reg-toolbar .site-picker { min-width: 220px; }
.reg-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 767.98px) {
  .reg-toolbar { width: 100%; }
  .reg-toolbar .day-picker { flex: 1 1 100%; }
  .reg-toolbar .site-picker { flex: 1 1 60%; min-width: 0; }
  .reg-toolbar > .btn { flex: 0 0 auto; }
  .reg-actions { width: 100%; margin-top: .5rem; }
  .reg-actions .btn { flex: 1 1 auto; }
}

/* Who is signed in: the name reads first, the role sits quietly under it
   rather than running along beside it. */
.navbar .nav-link.user-menu { display: flex; align-items: center; gap: .5rem; padding-top: .25rem; padding-bottom: .25rem; }
.navbar .nav-link.user-menu .fa-user-circle { font-size: 1.35rem; color: #6c757d; }
.navbar .nav-link.user-menu .who { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.navbar .nav-link.user-menu .who-name { font-weight: 600; color: #343a40; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navbar .nav-link.user-menu .who-role { font-size: .72rem; color: #7a8590; letter-spacing: .01em; }
@media (max-width: 400px) { .navbar .nav-link.user-menu .who-name { max-width: 42vw; } }

/* The setup checklist reads as a list: the mark in its own column, the task on
   one line, and the reason for it underneath. */
.setup-item { display: flex; align-items: flex-start; gap: .55rem; padding: .45rem 0; border-bottom: 1px dashed #e9edf1; }
.setup-item:last-child { border-bottom: 0; }
.setup-item > i { flex: 0 0 1rem; margin-top: .25rem; font-size: .85rem; }
.setup-item > div { min-width: 0; }
.setup-item .task { font-weight: 500; }
.setup-item .why { display: block; margin-top: .05rem; }

/* On a phone the office screens get thumbs, not a mouse pointer: the small
   buttons and pickers that make a dense desktop table readable are too small
   to hit. Nothing moves on a desktop. */
@media (max-width: 767.98px) {
  .btn-xs, .btn-sm, .btn {
    min-height: 38px;
    padding-top: .35rem;
    padding-bottom: .35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .form-control-sm, select.form-control-sm, .custom-select-sm { height: 38px; font-size: .9rem; }
  .table td .btn-xs + .btn-xs, .table td form + form { margin-top: .25rem; }
  /* A tick box you can actually hit: the label carries the target, and the
     box itself keeps its size. */
  .custom-control.custom-checkbox { min-height: 32px; padding-top: .15rem; }
  .custom-control-label { padding: .3rem 0 .3rem .15rem; }
  /* Icon-only actions need width as well as height to be worth aiming at. */
  .btn-xs > .fas, .btn-sm > .fas { font-size: .95rem; }
}
@media (max-width: 767.98px) {
  .form-control-file { padding: .45rem 0; min-height: 38px; }
}

/* The register is marked on a phone, standing at a gate, one thumb: the whole
   cell is the target, not the 13px dot in the middle of it. */
.choice .att-mark { display: flex; align-items: center; justify-content: center; min-height: 34px; margin: 0; cursor: pointer; }
.choice input[type="radio"] { width: 18px; height: 18px; }
@media (max-width: 767.98px) {
  .choice .att-mark { min-height: 44px; }
  .choice input[type="radio"] { width: 22px; height: 22px; }
}
@media (max-width: 767.98px) {
  .custom-control-label { padding: .45rem 0 .45rem .15rem; }
}
@media (max-width: 767.98px) {
  .form-control, input[type="date"].form-control, input[type="month"].form-control { min-height: 38px; }
}

/* KCB pages: a small form tucked under a row, opened when needed. */
.kcb-details summary { cursor: pointer; color: #007bff; font-size: .85rem; margin-top: .25rem; }
.kcb-details[open] summary { margin-bottom: .25rem; }
.kcb-url { resize: none; word-break: break-all; font-size: .8rem; }
/* A folded cell whose value runs to several lines keeps them together, beside
   its label (assets/js/app.js wraps them). */
@media (max-width: 767.98px) {
  table.stackable > tbody > tr > td > .cell-val { flex: 1 1 auto; min-width: 0; text-align: right; }
  table.stackable > tbody > tr > td > .cell-val .form-control { text-align: left; }
}
